/******************************************************************************

 ******************************************************************************
  File Name	:indicator.h
  Version		:001
  Author		:liangH
  Description	:define indicator class for alarm
  History		:20120727 new
  Modification	: 

******************************************************************************/

#ifndef __INDICATOR_H__
#define __INDICATOR_H__

#include "config.h"
//#include "hi_gpio.h"
#if 0
typedef struct {
	unsigned int  groupnumber;
	unsigned int  bitnumber;
	unsigned int  value;
}gpio_groupbit_info;

#define GPIO_SET_DIR 	0x1
#define GPIO_GET_DIR 	0x2
#define GPIO_READ_BIT 	0x3
#define GPIO_WRITE_BIT	0x4
#endif

class Indicator
{
	/*variable*/
	private: 
		int fd;/*file description of gpio indicator*/
		char gpio_dev_name[18];/*device name of gpio indicator*/
		unsigned char slowly_pthread_flag;/*the flag of slowly light pthread*/
		unsigned char fastly_pthread_flag;/*the flag of fastly light pthread*/
		unsigned short slowly_light_flag;/*the indicator flag of slowly light*/
		unsigned short fastly_light_flag;/*the indicator flag of fastly light*/
		pthread_t p_slowly_light_id;/*the pthread id of slowly light pthread*/
		pthread_t p_fastly_light_id;/*the pthread id of fastly light pthread*/
		pthread_mutex_t read_write_lock;/*read and write lock*/
	/*constructed function and deconstructed function*/

	public:
		Indicator();/*constructed function*/
		~Indicator();/*deconstructed function*/
		
	public:
	/*set,get member functin*/
		void set_gpio_dev_name(char *temp_dev_name);
		void get_gpio_dev_name(char *temp_dev_name);
		unsigned char get_slowly_pthread_flag();
		void set_slowly_pthread_flag(unsigned char temp_slowly_pthread_flag);
		unsigned char get_fastly_pthread_flag();
		void set_fastly_pthread_flag(unsigned char temp_fastly_pthread_flag);
	/*set,get member functin end*/

	/*basic function*/
		void light(unsigned char gpio_object);/*indicator lights*/
		void clear(unsigned char gpio_object);/*indicator darks*/
		void fast_light();/*indicator fastly lights*/
		void slow_light();/*indicator slowly lights*/
		void set_slowly_light_flag(unsigned char gpio_object);/*set lowly light flag of gpio_object*/
		void clear_slowly_light_flag(unsigned char gpio_object);/*clear lowly light flag of gpio_object*/
		unsigned short get_slowly_light_flag();/*get lowly light flag*/
		void set_fastly_light_flag(unsigned char gpio_object);/*set fastly light flag of gpio_object*/
		void clear_fastly_light_flag(unsigned char gpio_object);/*clear fastly light flag of gpio_object*/
		unsigned short get_fastly_light_flag();/*get fastly light flag*/
		void indicator_init();/*initialize indicator*/
		int setbit_gpio(unsigned int gpio_groupnum, unsigned int gpio_bitnum, unsigned int bitvalue);
		int getbit_gpio(unsigned int gpio_groupnum, unsigned int gpio_bitnum, unsigned int* bitvalue);
		int setdir_gpio(unsigned int gpio_groupnum, unsigned int gpio_bitnum, unsigned int gpio_dir );
		int start_indicator_thread(unsigned char thread_flag);
		int stop_indicator_thread(unsigned char thread_flag);
	/*basic function end*/
	
	private:	
	/*inside process function*/
		int open_gpio(void);
		int close_gpio(void);
		int getdir_gpio(unsigned int gpio_groupnum, unsigned int gpio_bitnum, unsigned int* gpio_dir);
	/*inside process function end*/	
 };

#endif
